package com.qf.controller;

import com.qf.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/*
 *@Description:
 *@author:刘哥
 *@Date:86180 2022/8/30 19:27
 */
@RequestMapping("/test")
// @ResponseBody//这个注解的作用,将当前方法的返回值解析为响应正文,我们现在期望转成json之后再作为响应正文返回,需要导入jackson-databind依赖包,否则会出现406错误
//@ResponseBody
//@Controller
@RestController
public class RespController {
    @RequestMapping("test01")
    public String test01(){
        System.out.println("响应正文回写中");
        return "success";
    }
    @RequestMapping("test02")
    public User test02(){
        User user=new User();
        user.setName("申志恒");
        user.setAge(18);
//        user.setAddress("北京");
        user.setAddress(null);
        return user;
    }
    @RequestMapping("test03")

    public Map test03(){
        HashMap map=new HashMap<>();
        map.put("name", "张三");
        map.put("context", "学不会就抓紧时间留级");
        return map;
    }

}
